﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include <stdio.h> 
//代码1 
void test1()
{
    int n = 10;
    int m = 20;
    int* p = &n;
    *p = 20;//ok? 
    p = &m; //ok? 
}
void test2()
{
    //代码2 
    int n = 10;
    int m = 20;
    const int* p = &n;
    *p = 20;//报错
    p = &m; //ok? 
}
void test3()
{
    int n = 10;
    int m = 20;
    int* const p = &n;
    *p = 20; //ok? 
    p = &m; //报错 
}
void test4()
{
    int n = 10;
    int m = 20;
    int const* const p = &n;
    *p = 20; //报错 
    p = &m; //报错 
}
int main()
{
    //测试⽆const修饰的情况 
    test1();
    //测试const放在*的左边情况 
    test2();
    //测试const放在*的右边情况 
    test3();
    //测试*的左右两边都有const 
    test4();
    return 0;
}